{% extends "base.html" %}

{% block content %}
    <div class="title" style="margin: auto;">
        <span id="index">
            <a href="{{ url('manage', 'index') }}">首页</a>
        </span>
        <div>
            域名：<span id="netloc">{{ netloc }}</span>
        </div>
    </div>

    <table class="gridtable" style="margin: auto">
        <tr>
            <th>代理</th>
            <th>过期时间</th>
            <th>使用次数</th>
            <th>操作</th>
        </tr>
        {% if length(all_proxy) != 0 %}
            {% for proxy in all_proxy %}
                <tr>
                    <td>{{ proxy['proxy'] }}</td>
                    {% if proxy.get('expiration', None) %}
                        <td>{{ proxy['expiration'] }}</td>
                    {% else %}
                        <td>无</td>
                    {% endif %}
                    <td>{{ integer(proxy['use_times']) }}</td>
                    <td>
                        <a class="del" href="">删除</a>
                    </td>
                </tr>
            {% endfor %}
        {% else %}
            <tr>
                <td>无</td>
                <td>无</td>
                <td>无</td>
                <td>无</td>
            </tr>
        {% endif %}
        </table>

{% endblock %}

{% block js %}
    <script>
        $(function () {
            $('.del').click(function () {
                var proxy = $(this).parent().parent().children()[0].innerText;
                var netloc = $('#netloc').text();
                $.ajax({
                    url: "{{ url('manage', 'proxy_delete') }}",
                    type: "GET",
                    data: {"proxy": proxy, "netloc": netloc},
                    success: function (message) {
                        if (message.code === 1000){
                            location.reload();
                        }
                    }
                })
                return false
            });
        })
    </script>
{% endblock %}